package com.yicoollxing.controller.backend;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yicoollxing.common.Const;
import com.yicoollxing.common.ServerResponse;
import com.yicoollxing.pojo.User;
import com.yicoollxing.service.IEvaluateService;
import com.yicoollxing.service.IUserService;


@Controller
@RequestMapping("/manager/evaluate")
public class EvaluateManagerController {
   //评论列表
	
	@Autowired
	private IUserService iUserService;
	
	@Autowired
	private IEvaluateService iEvaluateService;
	
	@ResponseBody
	@RequestMapping("/list.do")
	public ServerResponse list(Integer mid,@RequestParam(value="pageNum",defaultValue="1")Integer pageNum,
			         @RequestParam(value="pageSize",defaultValue="10")Integer pageSize,HttpSession session){

		User user = (User) session.getAttribute(Const.CURRENT_USER);
		if (user == null) {
			return ServerResponse.createByErrorMessage("请重新登录");
		}
		ServerResponse response = iUserService.checkAdminRole(user);
		if (!response.isSuccess()) {
			return response;
		}
		
		return iEvaluateService.list(pageNum, pageSize, mid);
	}
}
